<?php
class EmployeeApp extends MemberbaseApp {
	var $_user_mod;
    function __construct() {
        $this->EmployeeApp();
    }
    function EmployeeApp() {
        parent::__construct();
        $this->_user_mod =& m('member');
    }
    function index() {
		$page = $this->_get_page();
		$user_info = $this->visitor->get();
        $employee_list = $this->_user_mod->find(array(
        		'conditions' => 'activation=1 and role in('.USER_MERCHANDISER.','.USER_MERCHANDISER_ADMIN.','.USER_QC.','.USER_OUTGOING.','.USER_CHUANWU.','.USER_CIVILIAN.')',
				'count' => true,
				'limit' => $page['limit']
        ));
		$page['item_count'] = $this->_user_mod->getCount();
		$this->_format_page($page);
		$this->assign('page_info', $page);
        $this->assign('employee_list', $employee_list);
        $this->display('employee.list.html');
        $this->_curlocal(Lang::get('employee_list'));
    }
    function  show() {
        $user_id = intval($_GET['uid']);
        if (!$user_id) {
            $this->show_warning('member_not_exist');
            return;
        }
        $member_info = $this->_user_mod->get(array(
        	'conditions'=>'activation=1 and user_id='.$user_id
        ));
        if (empty($member_info)) {
            $this->show_warning('member_not_exist');
            return;
        }
        $file_mod=&m('upload');
        if (!empty($member_info)){
        	$member_info['member_img']=$file_mod->find(array(
        			'conditions' => 'file_type = ' . BELONGS_MEMBER_IMG . ' AND key_id = ' . $user_id,
        			'order' => 'file_id ASC',
        	));
        }
        $this->assign('employees', $member_info);
        $this->display('employee.info.html');
    }
}

?>
